using System;
using System.Data;
using System.Data.Common;
using System.Collections.Generic;
using System.Text;

using PickGold;
using PickGold.Database;

namespace PickGold.Entities.Table
{
    public class CExtendRoleUser : CExtendTable
    {
        //
        public const string ENTITY_NAME = "te_sys_role_user";
        public const string ENTITY_ALIAS = "role_user";
        //
        public const string ROLE_ID = CBaseRoleInfo.ENTITY_KEY;
        public const string USER_ID = CBaseUserInfo.ENTITY_KEY;
        public const string ITEM_NOTE = "item_note";
        //
        private SExtendRoleUser _ = null;
        //
        public CExtendRoleUser() : base(ENTITY_NAME, ENTITY_ALIAS) { }
        public CExtendRoleUser(CDatabase db) : base(db, ENTITY_NAME, ENTITY_ALIAS) { }
        public CExtendRoleUser(string alias) : base(ENTITY_NAME, alias) { }
        public CExtendRoleUser(CDatabase db, string alias) : base(db, ENTITY_NAME, alias) { }
        //
        protected override void SetSchema()
        {
            this.SetSchema(new SExtendRoleUser());
        }
        protected void SetSchema(SExtendRoleUser s)
        {
            this._ = s;
            base.SetSchema(s);
        }
        //
        protected override void PreInitSchema()
        {
            base.PreInitSchema();
            this._DataTable.Columns.Add(ROLE_ID, typeof(long)).DefaultValue = this._.RoleID;
            this._DataTable.Columns.Add(USER_ID, typeof(long)).DefaultValue = this._.UserID;
            this._DataTable.Columns.Add(ITEM_NOTE, typeof(string)).MaxLength = 50;
        }
        //
        protected override List<DataColumn> AddKeyColumn()
        {
            List<DataColumn> list = base.AddKeyColumn();
            list.Add(this._DataTable.Columns[ROLE_ID]);
            list.Add(this._DataTable.Columns[USER_ID]);
            return list;
        }
        //
        #region Property
        //
        public long RoleID
        {
            set
            {
                this._.RoleID = value;
                this.SetValue(ROLE_ID, value);
            }
            get
            {
                return this._.RoleID;
            }
        }
        //
        public long UserID
        {
            set
            {
                this._.UserID = value;
                this.SetValue(USER_ID, value);
            }
            get
            {
                return this._.UserID;
            }
        }
        //
        public string ItemNote
        {
            set
            {
                this._.ItemNote = value;
                this.SetValue(ITEM_NOTE, value);
            }
            get
            {
                return this._.ItemNote;
            }
        }
        //
        #endregion
        //
        public override bool MoveTo(int position)
        {
            if (!base.MoveTo(position))
                return false;
            this._.RoleID = this.GetValue<long>(ROLE_ID);
            this._.UserID = this.GetValue<long>(USER_ID);
            this._.ItemNote = this.GetValue<string>(ITEM_NOTE);
            return true;
        }
        //
    }
    //
    public class SExtendRoleUser : SExtendTable
    {
        //
        public long RoleID = -1;
        public long UserID = -1;
        public string ItemNote = null;
        //
    }
    //
}
//
